package utils;

/**
 * 分页工具类
 */
public class PageBean {
    private int total; //总记录数
    private int pageSize = 8;
    private int currentPage; //当前页
    private int startPage = (currentPage-1)*pageSize; //查询起始点
    private int totalPage;

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        if(total>0){
            this.total = total;
            this.setTotalPage();
        }
    }

    public int getTotalPage() {
        return totalPage;
    }

    public void setTotalPage() {
        if(this.total % this.pageSize == 0){
            this.totalPage = this.total / this.pageSize;
        }else if(this.total % this.pageSize > 0){
            this.totalPage = this.total / this.pageSize + 1;
        }else{
            this.totalPage = 0;
        }
    }

    public int getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(int currentPage) {
        if(currentPage>0){
            this.currentPage = currentPage;
        }
    }

    public int getStartPage() {
        return (this.getCurrentPage()-1)*pageSize;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }
}
